'image example from http://cairographics.org/samples'

out_file_name = __file__[:-1] + 'ng'#'example_image.png'

surface_width = 256
surface_height = 256

import os
os.environ['_CAIRO_LIBRARY_'] = 'cairo_1_10_2'

from cairo_ctypes import *

surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, surface_width, surface_height);
cr = cairo_create(surface)

image = cairo_image_surface_create_from_png ('romedalen.png');
w = cairo_image_surface_get_width (image);
h = cairo_image_surface_get_height (image);

cairo_translate (cr, 128.0, 128.0);
cairo_rotate (cr, 45* M_PI/180);
cairo_scale  (cr, 256.0/w, 256.0/h);
cairo_translate (cr, -0.5*w, -0.5*h);

cairo_set_source_surface (cr, image, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (image);

cairo_surface_write_to_png(surface, out_file_name)

print('Result see in %s' % out_file_name)
